import { stringify } from 'qs';
import request from '@/utils/request';
import {formDataCode} from '@/utils/utils';

// 获取上门自提地址列表
export async function GetPickupAddressPageData(params) {
  return request(`/${window.storeId}/Address/GetPickupAddressPageData?${stringify(params)}`);
}

// 增加自提地址信息
export async function AddPickupAddress(params) {
  return request(`/${window.storeId}/Address/AddPickupAddress`, {
    method: 'POST',
    body: {
      ...params
    }
  });
}

// 修改自提地址信息
export async function EditPickupAddress(params) {
  return request(`/${window.storeId}/Address/EditPickupAddress`, {
    method: 'POST',
    body: {
      ...params
    }
  });
}

// 删除指定自提点地址信息
export async function DeletePickupAddress(params) {
  return request(`/${window.storeId}/Address/DeletePickupAddress`, {
    method: 'POST',
    headers:{
      'Content-Type':"application/x-www-form-urlencoded",
   },
   body: formDataCode(params)
  });
}

// 启用/禁用自提点
export async function SetPickupAddressEnable(params) {
  return request(`/${window.storeId}/Address/SetPickupAddressEnable`, {
    method: 'POST',
    headers:{
      'Content-Type':"application/x-www-form-urlencoded",
   },
   body: formDataCode(params)
  });
}

// 开启上门自提
export async function OpenSelfFetchDelivery(params) {
  return request(`/${window.storeId}/Express/OpenSelfFetchDelivery`, {
    method: 'POST',
    body: params
  });
}

// 关闭上门自提
export async function CloseSelfFetchDelivery(params) {
  return request(`/${window.storeId}/Express/CloseSelfFetchDelivery`, {
    method: 'POST',
    body: params
  });
}

// 获取上门自提配置信息
export async function GetSelfFetchConfig(params) {
  return request(`/${window.storeId}/Express/GetSelfFetchConfig`);
}

// 上门自提支付方式保存
export async function SaveSelfFetchSupportPay(params) {
  return request(`/${window.storeId}/Express/SaveSelfFetchSupportPay`, {
    method: 'POST',
    headers:{
      'Content-Type':"application/x-www-form-urlencoded",
   },
   body: formDataCode(params)
  });
}
